{{extend 'layout.html'}}

<h2 class="fancy">PyForum - Manage Categories</h2>

{{include 'fadmin/admin_options.html'}}

{{if view_info.has_key('sort_saved'):}}<p class="information">Categories have been re-sorted</p>{{pass}}

{{if request.vars.updated:}}
    <div class="information">Category has been udpated.</div>
{{pass}}

{{include 'default/err_check.html'}}

{{if categories:}}
    <form id="cat_handling_form" method="post">
    <fieldset id="cat_handling_form_fields">
        <input type="hidden" id="form_submitted" name="form_submitted" value="1" />
        <table class="bordered" style="width: 100%;">
        <thead>
            <tr>
                <th>Order</th>
                <th>Title</th>
                <th>Description</th>
                <th>Visible To</th>
            </tr>
        </thead>
        <tbody>
            {{for idx, cat in enumerate(categories):}}
                <tr>
                    <td>
                        <input type="text" id="cat_id_{{=cat.id}}" name="cat_id_{{=cat.id}}"
                        value="{{=cat.cat_sort}}" style="width:50px;" />
                    </td>
                    <td>
                        <a href="{{=URL(r=request, c='fadmin', f='edit_category', args=[cat.id])}}"
                        title="Edit This Category">{{=cat.cat_name}}</a></td>
                    <td>{{=cat.cat_desc}}</td>
                    <td>{{if cat.cat_visible_to:}}{{=cat.cat_visible_to}}{{else:}}<b class="warning">Publicly Visible</b>{{pass}}</td>
                </tr>
            {{pass}}
        </tbody>
        </table>

        <div class="top-separator">
            <input type="submit" id="save_sort" name="save_sort" value="Save Sort Order" />
            <input type="submit" id="add_cat" name="add_cat" value="Add New Category" />
        </div>
    </fieldset>
    </form>
{{else:}}
    <p class="warning">No categories Found.</p>
    <form id="cat-handling-form" method="post">
        <fieldset id="cat-handling-form-fields">
            <input type="hidden" id="form_submitted" name="form_submitted" value="1" />
            <div class="top-separator">
                <input type="submit" id="add_cat" name="add_cat" value="Add New Category" />
            </div>
        </fieldset>
    </form>
{{pass}}
